package com.vmtest;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
//import android.widget.PopupWindow;
import android.widget.Spinner;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;

import com.vmtest.R;

public class frmprevisitas extends Activity {
	
	ViewFlipper vflipperME;
	ViewFlipper vflipperCS;
	ViewFlipper vflipperFA;
	
	TabHost tabs;

	final Context context = this;	
	public static int cont = 0;
	
/*	Listview selected row
	private int mSelectedRow = 0;
	Right arrow icon on each listview row
	private ImageView mMoreIv = null;
	
	private static final int ID_ADD = 1;
	private static final int ID_ACCEPT = 2;
	private static final int ID_UPLOAD = 3;
	private static final int ID_PREVISIT = 4;
	*/
	
	// Evento al usar el boton de retorno
	@Override
	public void onBackPressed() {
		
	    // do something on back.
		//this.startActivity(new Intent(frmficheros.this,frmPpal.class));
		
		// custom dialog
				final Dialog dialog = new Dialog(context);
				dialog.setContentView(R.layout.dialogmenu);
				dialog.setTitle("Previsitas");

				// set the custom dialog components - text, image and button
				TextView text = (TextView) dialog.findViewById(R.id.text);
				text.setText("¿Desea salir del modulo?");
				
				//personalizacion de imagen
				//ImageView image = (ImageView) dialog.findViewById(R.id.image);
				//image.setImageResource(R.drawable.ic_launcher);

				Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
				Button dialogButton1 = (Button) dialog.findViewById(R.id.dialogButtonCANCEL);
				// if button is clicked, close the custom dialog
				dialogButton.setOnClickListener(new OnClickListener() {
					//@Override
					public void onClick(View v) {
						//dialog.dismiss();
						Intent intentppal = new Intent(frmprevisitas.this, frmPpal.class);
	            		startActivity(intentppal); 
					}
				});
				
				dialogButton1.setOnClickListener(new OnClickListener() {
					//@Override
					public void onClick(View v) {
						dialog.dismiss();
					}
				});

				dialog.show();
		
	    return;
	}
	
public void ExitApp() {
		
	    // do something on back.
		//this.startActivity(new Intent(frmficheros.this,frmPpal.class));
		
		// custom dialog
				final Dialog dialog = new Dialog(context);
				dialog.setContentView(R.layout.dialogmenu);
				dialog.setTitle("Previsitas");

				// set the custom dialog components - text, image and button
				TextView text = (TextView) dialog.findViewById(R.id.text);
				text.setText("¿Desea salir de la aplicacion?");
				
				//personalizacion de imagen
				//ImageView image = (ImageView) dialog.findViewById(R.id.image);
				//image.setImageResource(R.drawable.ic_launcher);

				Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
				Button dialogButton1 = (Button) dialog.findViewById(R.id.dialogButtonCANCEL);
				// if button is clicked, close the custom dialog
				dialogButton.setOnClickListener(new OnClickListener() {
					//@Override
					public void onClick(View v) {
						//dialog.dismiss();
						Intent intentlogin = new Intent(frmprevisitas.this, LoginActivity.class);
	            		startActivity(intentlogin); 
	            	       finishFromChild(getParent());
	            	       moveTaskToBack(true);
					}
				});
				
				dialogButton1.setOnClickListener(new OnClickListener() {
					//@Override
					public void onClick(View v) {
						dialog.dismiss();
					}
				});

				dialog.show();
		
	    return;
	}
	
	public void onTabChanged() {
		if (tabs.getCurrentTab()==0) { 
    		vflipperME.setDisplayedChild (3);
        } else if (tabs.getCurrentTab()==1) {
            vflipperCS.setDisplayedChild (3);
        } else if (tabs.getCurrentTab()==2) {
            vflipperFA.setDisplayedChild (3);
        } 
	}

	public void onTabChanged(String arg0) {
        Log.i("******Clickin Tan number ... ", "" + tabs.getCurrentTab());
       }   
		
	/* eventos a realizar al cargar formulario*/
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);    	
		setContentView(R.layout.frmprevisitas);	
	
		/*viewflipper medicos*/
		vflipperME = (ViewFlipper) findViewById(R.id.viewFlipperME);
		vflipperCS = (ViewFlipper) findViewById(R.id.viewFlipperCS);
		vflipperFA = (ViewFlipper) findViewById(R.id.viewFlipperFA);
			
		//registerForContextMenu(getListView());
				
		//*** Carga Spinner Filtro - Medicos ***//	
		Spinner prueba = (Spinner) findViewById(R.id.spinpreme);
		//Creamos el adaptador
		ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.filtroficheroME,android.R.layout.simple_spinner_item);		
		//Añadimos el layout para el menú
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		//Le indicamos al spinner el adaptador a usar
		prueba.setAdapter(adapter);
		
		//*** Carga Spinner Filtro - CS ***//		
		Spinner prueba1 = (Spinner) findViewById(R.id.spinprecs);
		ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(this,R.array.filtroficheroCS,android.R.layout.simple_spinner_item);
		adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		prueba1.setAdapter(adapter1);		
		
		//*** Carga Spinner Filtro - Farmacias ***//
		Spinner prueba11 = (Spinner) findViewById(R.id.spinprefa);
		ArrayAdapter<CharSequence> adapter11 = ArrayAdapter.createFromResource(this,R.array.filtroficheroFA,android.R.layout.simple_spinner_item);
		adapter11.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		prueba11.setAdapter(adapter11);
		
	
		/* cargar pestañas */
		Resources res = getResources();
        
        //TabHost tabs=(TabHost)findViewById(android.R.id.tabhost);
		tabs=(TabHost)findViewById(android.R.id.tabhost);
        tabs.setup();
        
        TabHost.TabSpec 
        spec=tabs.newTabSpec("mitab1");
        spec.setContent(R.id.tab1);
        spec.setIndicator("", res.getDrawable(R.drawable.iconome));
        tabs.addTab(spec);
        
        spec=tabs.newTabSpec("mitab2");
        spec.setContent(R.id.tab2);
        spec.setIndicator("", res.getDrawable(R.drawable.iconocs));
        tabs.addTab(spec);
        
        spec=tabs.newTabSpec("mitab3");
        spec.setContent(R.id.tab3);
        spec.setIndicator("", res.getDrawable(R.drawable.iconofa));
        tabs.addTab(spec);
         
        tabs.setCurrentTab(0); 
        
        //static TabHost tabHost;
        //tabHost = getTabHost();
        //tabs = getTabHost();
        
        
        
        /*Instanciar listviews a cargar*/  
        /*Listview menu principal*/
		final ListView l = (ListView) findViewById(R.id.listView1);					 
		l.setAdapter(new miAdapter(this));
		
		
		
		/*Listview de observaciones medico*/
		final ListView lvME = (ListView) findViewById(R.id.listplanme);	 
		lvME.setAdapter(new miAdapterlvMe(this));
		
		/*listview de observaciones de centros de salud*/
		final ListView lvCS = (ListView) findViewById(R.id.listplancs);	 
		lvCS.setAdapter(new miAdapterlvCS(this));
		
		/*listview de observaciones de farmacias*/
		final ListView lvFA = (ListView) findViewById(R.id.listplanfa);	 
		
		lvFA.setAdapter(new miAdapterlvFA(this));
		
		
		
		/*Listview de plan promocional medico*/
		final ListView lvvisitasME = (ListView) findViewById(R.id.listvisitasme);	 
		lvvisitasME.setAdapter(new miAdapterlvvisitasMe(this));
		
		/*listview de plan promocional de centros de salud*/
		final ListView lvvisitasCS = (ListView) findViewById(R.id.listvisitascs);	 
		lvvisitasCS.setAdapter(new miAdapterlvvisitasCS(this));
		
		/*listview de plan promocional de farmacias*/
		final ListView lvvisitasFA = (ListView) findViewById(R.id.listvisitasfa);	 
		lvvisitasFA.setAdapter(new miAdapterlvvisitasFA(this));
		
		
        
		/*Menu contextual listview (QuickAction)
		
		Items del menu contextual
		ActionItem acceptItem 	= new ActionItem(ID_ACCEPT, "Modificar", getResources().getDrawable(R.drawable.ic_accept));
        ActionItem uploadItem 	= new ActionItem(ID_UPLOAD, "Eliminar", getResources().getDrawable(R.drawable.ic_up));
        ActionItem previsitItem 	= new ActionItem(ID_PREVISIT, "Pre-Visitar", getResources().getDrawable(R.drawable.ic_prev));
        
		final QuickAction mQuickAction 	= new QuickAction(this);
		
		//mQuickAction.addActionItem(addItem);
		mQuickAction.addActionItem(acceptItem);
		mQuickAction.addActionItem(uploadItem);
		mQuickAction.addActionItem(previsitItem);
		
		//setup the action item click listener
		mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
			@Override
			public void onItemClick(QuickAction quickAction, int pos, int actionId) {
				ActionItem actionItem = quickAction.getActionItem(pos);
				
				if (actionId == ID_ADD) { //Add item selected
					Toast.makeText(getApplicationContext(), "Add item selected on row " + mSelectedRow, Toast.LENGTH_SHORT).show();
				} else {
					Toast.makeText(getApplicationContext(), actionItem.getTitle() + " item selected on row " 
							+ mSelectedRow, Toast.LENGTH_SHORT).show();
				}	
			}
		});
		
		//setup on dismiss listener, set the icon back to normal
		mQuickAction.setOnDismissListener(new PopupWindow.OnDismissListener() {			
			@Override
			public void onDismiss() {
				mMoreIv.setImageResource(R.drawable.ic_list_more);
			}
		});
		
		
		QuickAction para los distintintos listviews de fichero
		lvME.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				mSelectedRow = position; //set the selected row
				
				mQuickAction.show(view);
				
				//change the right arrow icon to selected state 
				mMoreIv = (ImageView) view.findViewById(R.id.i_more);
				mMoreIv.setImageResource(R.drawable.ic_list_more_selected);
			}
		});
		
		lvCS.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				mSelectedRow = position; //set the selected row
				
				mQuickAction.show(view);
				
				//change the right arrow icon to selected state 
				mMoreIv = (ImageView) view.findViewById(R.id.i_more);
				mMoreIv.setImageResource(R.drawable.ic_list_more_selected);
			}
		});
		
		lvFA.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				mSelectedRow = position; //set the selected row
				
				mQuickAction.show(view);
				
				//change the right arrow icon to selected state 
				mMoreIv = (ImageView) view.findViewById(R.id.i_more);
				mMoreIv.setImageResource(R.drawable.ic_list_more_selected);
			}
		});*/
		
		/*Eventos a realizar al sellecionar algun item del menu principal*/
		l.setOnItemClickListener(new OnItemClickListener() {	

			//@Override
            public void onItemClick(AdapterView<?> parent, View v, int posicion, long id) {  
            	         	            	
            	switch (posicion){
            	case 0:
            		Intent intentfic = new Intent(frmprevisitas.this, frmficheros.class);
            		startActivity(intentfic);
            		break;
            	case 1:
            		/*Intent intentprev = new Intent(frmprevisitas.this, frmprevisitas.class);
            		startActivity(intentprev); */
            		break;
            	case 2:
            		Intent intentpost = new Intent(frmprevisitas.this, frmpostvisitas.class);
            		startActivity(intentpost); 
            		break;  
            	case 3:
            		Intent intentnotif = new Intent(frmprevisitas.this, frmnotificaciones.class);
            		startActivity(intentnotif); 
            		break;  
            	case 4:
            		Intent intentrep = new Intent(frmprevisitas.this, frmreportes.class);
            		startActivity(intentrep); 
            		break;  
            	case 5:
            		Intent intentaus = new Intent(frmprevisitas.this, frmausencias.class);
            		startActivity(intentaus); 
            		break;  
            	case 6:
            		Intent intentsinc = new Intent(frmprevisitas.this, frmsincronizar.class);
            		startActivity(intentsinc); 
            		break;  
            	case 7:
            		Intent intentconf = new Intent(frmprevisitas.this, frmconfiguracion.class);
            		startActivity(intentconf); 
            		break;  
            	case 8:
            		ExitApp();
            		break;  
            	}               
            }                
        });		                                                     
    }
    
    /*Referencia a base de datos - No funciona*/
	public void DisplayContact(Cursor c) {
		Toast.makeText(
				this,
				//"id: " + c.getString(0) + "\n" + "Usuario: " + c.getString(1) + "\n" + "Clave: " + c.getString(2), Toast.LENGTH_LONG)
				"Centro: " + c.getString(0) + "\n" + "Ciudad: " + c.getString(1), Toast.LENGTH_LONG)
		.show();
	}
	
	/*cargar item del listview de menu principal*/
	private static class miAdapter extends BaseAdapter {
 
		private LayoutInflater mInflater;
 
		private static final String[][] data = {{"Ficheros","1"}, {"PreVisitas","2"}, {"PostVisitas","3"}, {"Notificaciones","4"}, {"Reportes","5"}, {"Ausencias","6"}, {"Sincronizar","7"}, {"Configuracion","8"}, {"Salir","9"}};
		
		private static final int[][] dataimg =  {{R.drawable.icono,1},{R.drawable.icono1,2},{R.drawable.icono2,3},{R.drawable.icono3,4},{R.drawable.icono4,5},{R.drawable.icono5,6},{R.drawable.icono6,7},{R.drawable.icono7,8},{R.drawable.icono8,9}};
	
		public miAdapter(Context context) {
 
			mInflater = LayoutInflater.from(context);						
	    
		}
		
	
		
		public View getView(int position, View convertView, ViewGroup parent) {
 
 
			TextView text;
 
			ImageView img1;
 
 
			if (convertView == null) {
 
				convertView = mInflater.inflate(R.layout.listview_fila, null);				
 
			} 
 
			text = (TextView) convertView.findViewById(R.id.TextView01);
  
			img1 = (ImageView) convertView.findViewById(R.id.ImageView01);
 
			text.setText(data[position][0]);
			
			img1.setImageResource(dataimg[position][0]);
			
			//cambia estilo registro seleccionado en menu
			if (data[position][0] == "PreVisitas") {
				convertView.setSelected(true);
				convertView.setBackgroundResource(R.drawable.degrade_botonmenu);
			} else {
				convertView.setSelected(true);
				convertView.setBackgroundResource(R.drawable.degrade_transparent);
			}
			
			return convertView;						
		}
 
 
		public int getCount() {
			return data.length;
		}
 
 
		public Object getItem(int position) {
			return position;		
		}
 
 
		public long getItemId(int position) {
			return position;
		}		 
		
		
	}
	
	/*cargar item de listview de fichero de medicos*/
	private static class miAdapterlvMe extends BaseAdapter {
		 
		private LayoutInflater mInflater;
 
		private static final String[][] data = {{"Alvares, ","Tibisay","Especialidad: MEG","Frecuencia: 1","Visita: 0","1"}, {"Alvares, ","Tibisay","Especialidad: MEG","Frecuencia: 1","Visita: 0","2"}, {"Alvares, ","Tibisay","Especialidad: MEG","Frecuencia: 1","Visita: 0","3"}};
 
		public miAdapterlvMe(Context context) { 
			mInflater = LayoutInflater.from(context);	    
		}
		
		public View getView(int position, View convertView, ViewGroup parent) {
 
			TextView text;
			TextView text1;
			TextView text2;
			TextView text3;
			TextView text4; 

			if (convertView == null) { 
				convertView = mInflater.inflate(R.layout.listview_fila_ficherome , null); 
			} 
 
			text = (TextView) convertView.findViewById(R.id.TextView01);
			text1 = (TextView) convertView.findViewById(R.id.TextView02);
			text2 = (TextView) convertView.findViewById(R.id.TextView03);
			text3 = (TextView) convertView.findViewById(R.id.TextView04);
			text4 = (TextView) convertView.findViewById(R.id.TextView05);  

			text.setText(data[position][0]);
			text1.setText(data[position][1]);
			text2.setText(data[position][2]);
			text3.setText(data[position][3]);
			text4.setText(data[position][4]);
							
			return convertView; 
		}
 
 
		public int getCount() { 
			return data.length; 
		}
 
 
		public Object getItem(int position) { 
			return position;	 
		}
 
 
		public long getItemId(int position) { 
			return position; 
		}	
		
	}	
	
	/*cargar item de listview de fichero de centros de salud*/
	private static class miAdapterlvCS extends BaseAdapter {
		 
		private LayoutInflater mInflater;
 
		private static final String[][] data = {{"Alvares, ","Tibisay","Especialidad: MEG","Frecuencia: 1","Visita: 0","1"}, {"Alvares, ","Tibisay","Especialidad: MEG","Frecuencia: 1","Visita: 0","2"}};
 
		public miAdapterlvCS(Context context) { 
			mInflater = LayoutInflater.from(context);	    
		}
		
		public View getView(int position, View convertView, ViewGroup parent) {
 
			TextView text;
			TextView text1;
			TextView text2;
			TextView text3;
			TextView text4; 

			if (convertView == null) { 
				convertView = mInflater.inflate(R.layout.listview_fila_ficherocs , null); 
			} 
 
			text = (TextView) convertView.findViewById(R.id.TextView01);
			text1 = (TextView) convertView.findViewById(R.id.TextView02);
			text2 = (TextView) convertView.findViewById(R.id.TextView03);
			text3 = (TextView) convertView.findViewById(R.id.TextView04);
			text4 = (TextView) convertView.findViewById(R.id.TextView05);  

			text.setText(data[position][0]);
			text1.setText(data[position][1]);
			text2.setText(data[position][2]);
			text3.setText(data[position][3]);
			text4.setText(data[position][4]);
							
			return convertView; 
		}
 
 
		public int getCount() { 
			return data.length; 
		}
 
 
		public Object getItem(int position) { 
			return position;	 
		}
 
 
		public long getItemId(int position) { 
			return position; 
		}	
		
	}	
	
	/*cargar item de listview de fichero de farmacias*/
	private static class miAdapterlvFA extends BaseAdapter {
		 
		private LayoutInflater mInflater;
 
		private static final String[][] data = {{"Alvares, ","Tibisay","Especialidad: MEG","Frecuencia: 1","Visita: 0","1"}};
 
		public miAdapterlvFA(Context context) { 
			mInflater = LayoutInflater.from(context);	    
		}
		
		public View getView(int position, View convertView, ViewGroup parent) {
 
			TextView text;
			TextView text1;
			TextView text2;
			TextView text3;
			TextView text4; 

			if (convertView == null) { 
				convertView = mInflater.inflate(R.layout.listview_fila_ficherofa , null); 
			} 
 
			text = (TextView) convertView.findViewById(R.id.TextView01);
			text1 = (TextView) convertView.findViewById(R.id.TextView02);
			text2 = (TextView) convertView.findViewById(R.id.TextView03);
			text3 = (TextView) convertView.findViewById(R.id.TextView04);
			text4 = (TextView) convertView.findViewById(R.id.TextView05); 

			text.setText(data[position][0]);
			text1.setText(data[position][1]);
			text2.setText(data[position][2]);
			text3.setText(data[position][3]);
			text4.setText(data[position][4]);
							
			return convertView; 
		}
 
 
		public int getCount() { 
			return data.length; 
		}
 
 
		public Object getItem(int position) { 
			return position;	 
		}
 
 
		public long getItemId(int position) { 
			return position; 
		}	
		
	}	
		
	//	CARGAR OBSERVACIONES
	/*cargar item de listview de fichero de medicos*/
	private static class miAdapterlvvisitasMe extends BaseAdapter {
		 
		private LayoutInflater mInflater;
 
		private static final String[][] data = {
			{"1", "01/01/2012","Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario"}, 
			{"2", "01/01/2012","Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario"}, 
			{"3", "01/01/2012","Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario"}
		};
 
		public miAdapterlvvisitasMe(Context context) { 
			mInflater = LayoutInflater.from(context);	    
		}
		
		public View getView(int position, View convertView, ViewGroup parent) {
 
			TextView text;
			TextView text1;
			TextView text2;
			/*TextView text3;
			TextView text4; */

			if (convertView == null) { 
				convertView = mInflater.inflate(R.layout.listview_fila_previsitas , null); 
			} 
 
			text = (TextView) convertView.findViewById(R.id.textView1);
			text1 = (TextView) convertView.findViewById(R.id.TextView01);
			text2 = (TextView) convertView.findViewById(R.id.TextView03);
			/*text3 = (TextView) convertView.findViewById(R.id.TextView04);
			text4 = (TextView) convertView.findViewById(R.id.TextView05);  */

			text.setText(data[position][0]);
			text1.setText(data[position][1]);
			text2.setText(data[position][2]);
			/*text3.setText(data[position][3]);
			text4.setText(data[position][4]);*/
							
			return convertView; 
		}
 
 
		public int getCount() { 
			return data.length; 
		}
 
 
		public Object getItem(int position) { 
			return position;	 
		}
 
 
		public long getItemId(int position) { 
			return position; 
		}	
		
	}	
	
	/*cargar item de listview de fichero de centros de salud*/
	private static class miAdapterlvvisitasCS extends BaseAdapter {
		 
		private LayoutInflater mInflater;
 
		private static final String[][] data = {
			{"1", "01/01/2012","Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario"}, 
			{"2", "01/01/2012","Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario"}, 			
		};
 
		public miAdapterlvvisitasCS(Context context) { 
			mInflater = LayoutInflater.from(context);	    
		}
		
		public View getView(int position, View convertView, ViewGroup parent) {
 
			TextView text;
			TextView text1;
			TextView text2;
			/*TextView text3;
			TextView text4; */

			if (convertView == null) { 
				convertView = mInflater.inflate(R.layout.listview_fila_previsitas , null); 
			} 
 
			text = (TextView) convertView.findViewById(R.id.textView1);
			text1 = (TextView) convertView.findViewById(R.id.TextView01);
			text2 = (TextView) convertView.findViewById(R.id.TextView03);
			/*text3 = (TextView) convertView.findViewById(R.id.TextView04);
			text4 = (TextView) convertView.findViewById(R.id.TextView05);  */

			text.setText(data[position][0]);
			text1.setText(data[position][1]);
			text2.setText(data[position][2]);
			/*text3.setText(data[position][3]);
			text4.setText(data[position][4]);*/
							
			return convertView; 
		}
 
 
		public int getCount() { 
			return data.length; 
		}
 
 
		public Object getItem(int position) { 
			return position;	 
		}
 
 
		public long getItemId(int position) { 
			return position; 
		}	
		
	}	
	
	/*cargar item de listview de fichero de farmacias*/
	private static class miAdapterlvvisitasFA extends BaseAdapter {
		 
		private LayoutInflater mInflater;
 
		private static final String[][] data = {
			{"1", "01/01/2012","Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario Comentario"}
		};
 
		public miAdapterlvvisitasFA(Context context) { 
			mInflater = LayoutInflater.from(context);	    
		}
		
		public View getView(int position, View convertView, ViewGroup parent) {
 
			TextView text;
			TextView text1;
			TextView text2;
			/*TextView text3;
			TextView text4; */

			if (convertView == null) { 
				convertView = mInflater.inflate(R.layout.listview_fila_previsitas , null); 
			} 
 
			text = (TextView) convertView.findViewById(R.id.textView1);
			text1 = (TextView) convertView.findViewById(R.id.TextView01);
			text2 = (TextView) convertView.findViewById(R.id.TextView03);
			/*text3 = (TextView) convertView.findViewById(R.id.TextView04);
			text4 = (TextView) convertView.findViewById(R.id.TextView05);  */

			text.setText(data[position][0]);
			text1.setText(data[position][1]);
			text2.setText(data[position][2]);
			/*text3.setText(data[position][3]);
			text4.setText(data[position][4]);*/
							
			return convertView; 
		}
 
 
		public int getCount() { 
			return data.length; 
		}
 
 
		public Object getItem(int position) { 
			return position;	 
		}
 
 
		public long getItemId(int position) { 
			return position; 
		}	
		
	}	
}
